﻿@using HiLand.Utility4.MVC.Controls
@using HiLand.Framework.BusinessCore
@using GBFinance.Web.Models
@using GBFinance.Web.Control
@using HiLand.General.Entity
@model HiLand.Framework.BusinessCore.IBusinessUser
@{
    Layout = null;

    List<SelectListItem> sexItemList = HiLand.Utility4.Enums.EnumConverter.BuildSelectItemList<HiLand.Utility.Enums.Sexes>();
    List<SelectListItem> maritalStatusList = HiLand.Utility4.Enums.EnumConverter.BuildSelectItemList<HiLand.Utility.Enums.MaritalStatuses>();

    List<string> cssFiles = new List<string>() { Url.Content("~/Content/jQuery.tools.dateinput.css") };
    List<string> javaScriptFiles = new List<string>() { Url.Content("~/Scripts/jQuery.tools.min.js") };
    string dateTimeOptions = "{format: 'dd/mm/yyyy'}";
    string userBirthDay = string.Empty;
    if (Model != null && Model.UserBirthDay != null && Model.UserBirthDay != HiLand.Utility.Data.DateTimeHelper.Min)
    {
        userBirthDay = Model.UserBirthDay.ToString(Miscs.DateTimeFormating, Miscs.CurrentCultureInfo);
    }

    MvcControlUsingModes usingMode = (this.ViewContext.Controller as GBFinance.Web.Controllers.SecuredController).GetUsingMode();
    bool isPopLayer = (this.ViewContext.Controller as GBFinance.Web.Controllers.SecuredController).CheckIsPopLayer(); 


    ResidentalEntity residentalEntity = this.ViewBag.ResidentalEntity;
    ResidentalEntity residentalEntityPre = this.ViewBag.ResidentalEntityPre;
}
<div id="UApplicantDetailContainer">
    @using (Html.BeginForm())
    { 
        <fieldset id="personalDetails" class="simpleFieldset">
            <legend>Personal Details</legend>
            @Html.HiTextBox().Name("UserTitle").Value(Model.UserTitle).Lable("UserTitle").UsingMode(usingMode).Render()
            @Html.HiRadioButtonList().Name("UserSex").ItemList(sexItemList).Value(Model.UserSex.ToString()).Lable("Gender").UsingMode(usingMode).Render()
            @Html.HiTextBox().Lable("Position").Name("UserPosition").Value(Model.UserPosition).UsingMode(usingMode).Render()
            @Html.HiTextBox().Lable("First Name").Name("UserNameFirst").Value(Model.UserNameFirst).UsingMode(usingMode).Render()
            @Html.HiTextBox().Lable("Middle Name").Name("UserNameMiddle").Value(Model.UserNameMiddle).UsingMode(usingMode).Render()
            @Html.HiTextBox().Lable("SurName").Name("UserNameLast").Value(Model.UserNameLast).UsingMode(usingMode).Render()
            @Html.HiDateTime().Lable("Date of Birth").Name("UserBirthDay").StyleSheetFiles(cssFiles).JavaScriptFiles(javaScriptFiles).DateTimeOptions(dateTimeOptions).Value(userBirthDay).UsingMode(usingMode).Render()
            @Html.HiTextBox().Lable("Home telephone").Name("HomeTelephone").Value(Model.HomeTelephone).UsingMode(usingMode).Render()
            @Html.HiTextBox().Lable("Work telephone").Name("WorkTelphone").Value(Model.WorkTelphone).UsingMode(usingMode).Render()
            @Html.HiTextBox().Lable("Mobile Number").Name("UserMobileNO").Value(Model.UserMobileNO).UsingMode(usingMode).Render()
            @Html.HiTextBox().Lable("Email Address").Name("UserEmail").Value(Model.UserEmail).UsingMode(usingMode).Render()
            @Html.HiTextBox().Lable("Position").Name("UserPosition").Value(Model.UserPosition).UsingMode(usingMode).Render()
            @Html.HiDropDownList().Lable("Marital Status").Name("MaritalStatus").ItemList(maritalStatusList).Value((Model.MaritalStatus).ToString()).UsingMode(usingMode).Render()
            @Html.HiddenFor(m => m.UserGuid)
        </fieldset>

        <fieldset id="residentialDetails" class="simpleFieldset">
            <legend>Residential Details</legend>
            @Html.GBFResidentalTypeDropDownList().Name("ResidentialStatus").Value(((int)residentalEntity.ResidentialStatus).ToString()).Lable("Residential Status").UsingMode(usingMode).Render()
            @Html.HiTextBox().Name("UnitApartmentNo").Value(residentalEntity.ApartmentNo).Lable("Unit/Apartment No.").UsingMode(usingMode).Render()
            @Html.HiTextBox().Name("StreetNoAndName").Value(residentalEntity.Street).Lable("Street no. and name").UsingMode(usingMode).Render()
            @Html.HiTextBox().Name("Suburb").Value(residentalEntity.Suburb).Lable("Suburb").UsingMode(usingMode).Render()
            @Html.GBFAustraliaStateDropDownList().Name("State").Value(residentalEntity.State).Lable("State").UsingMode(usingMode).Render()
            @Html.HiTextBox().Name("Postcode").Value(residentalEntity.PostCode).Lable("Postcode").UsingMode(usingMode).Render()
            @Html.HiTextBox().Name("AddressYears").Value(residentalEntity.ResidentalYears.ToString()).Lable("AddressYears").UsingMode(usingMode).Render()
            @Html.HiTextBox().Name("AddressMonths").Value(residentalEntity.ResidentalMonths.ToString()).Lable("AddressMonths").UsingMode(usingMode).Render()
            @Html.Hidden("ResidentalGuid", residentalEntity.ResidentialGuid.ToString())
        </fieldset>
        
        <fieldset id="preResidentialDetails" class="simpleFieldset">
            <legend>Previous Residential Details</legend>
            @Html.HiTextBox().Name("PreUnitApartmentNo").Value(residentalEntityPre.ApartmentNo).Lable("Unit/Apartment No.").UsingMode(usingMode).Render()
            @Html.HiTextBox().Name("PreStreetNoAndName").Value(residentalEntityPre.Street).Lable("Street no. and name").UsingMode(usingMode).Render()
            @Html.HiTextBox().Name("PreSuburb").Value(residentalEntityPre.Suburb).Lable("Suburb").UsingMode(usingMode).Render()
            @Html.GBFAustraliaStateDropDownList().Name("PreState").Value(residentalEntityPre.State).Lable("State").UsingMode(usingMode).Render()
            @Html.HiTextBox().Name("PrePostcode").Value(residentalEntityPre.PostCode).Lable("Postcode").UsingMode(usingMode).Render()
            @Html.HiTextBox().Name("PreAddressYears").Value(residentalEntityPre.ResidentalYears.ToString()).Lable("AddressYears").UsingMode(usingMode).Render()
            @Html.HiTextBox().Name("PreAddressMonths").Value(residentalEntityPre.ResidentalMonths.ToString()).Lable("AddressMonths").UsingMode(usingMode).Render()
            @Html.Hidden("ResidentalGuidPre", residentalEntityPre.ResidentialGuid.ToString())
        </fieldset>
    }
    @if (isPopLayer == true)
    {
        <div class="notification attention png_bg">
            <a href="#" class="close">
                <img src="@Url.Content("~/Content/NotificationImages/cross_grey_small.png")" title="Close this notification"
            alt="close" /></a>
            <div class="notificationContent">
                You can close this PopWindow by the key "Esc".
            </div>
        </div>
        <input type="button" value="Save" id="btnSave" />
        <script type="text/javascript">
            $(document).ready(function () {
                $("#UApplicantDetailContainer #btnSave").click(function () {
                    $("#UApplicantDetailContainer form").ajaxSubmit({
                        success: function (responseInfo) {
                            if (responseInfo.IsSuccessful == false) {
                                alert(responseInfo.statusMessage);
                            }
                            else {
                                //alert(responseInfo.IsSuccessful);
                                window.location.reload();
                            }
                        },
                        data: { "isAjaxDeal": "true" }
                    });
                });
            });
        </script>
    }
</div>
